package ace.tool.generate.code.test.core.dao.entity;

import ace.cmp.data.api.annotation.Index;
import ace.cmp.spring.data.jdbc.querydsl.core.annotations.LogicDelete;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.annotation.Version;
import org.springframework.data.relational.core.mapping.Table;

/**
 * application and oauth2 registered client relation table entity
 *
 * @author Caspar
 * @since 2020-01-09
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "application and oauth2 registered client relation table entity")
@Index(
    name = "uk_app_application_oauth2_client_appid_biztypekey",
    unique = true,
    columns = {"app_id", "biz_type_key", "delete_flag"})
@Index(
    name = "uk_app_application_oauth2_client_idofclient",
    unique = true,
    columns = {"id_of_client", "delete_flag"})
@Table("app_application_oauth2_client")
public class AppApplicationOauth2Client implements Serializable {

  private static final String UK_ID_OF_CLIENT = "uk_app_application_oauth2_client_idofclient";

  @Schema(title = "id")
  @Id
  @NotNull
  private Long id;

  /**
   * app id
   */
  @NotNull private Long appId;

  /**
   * biz type key
   */
  @NotEmpty private String bizTypeKey;

  /**
   * oauth2 id of client
   */
  @NotEmpty private String idOfClient;

  /**
   * 标题
   */
  @NotNull private String title;

  /**
   * 备注
   */
  @NotNull private String remark;

  /**
   * data format is json map {@link java.util.Map<String,String>} for application authentication attributes
   */
  @NotNull private String attributes;

  /**
   * iam account application biz type id {@link IamAccountApplicationBizTypeDto}
   */
  @Nullable private Long accountAppBizTypeId;

  /**
   * upms application biz type id {@link UpmsApplicationBizTypeDto}
   */
  @Nullable private Long upmsAppBizTypeId;

  /**
   * 删除标识
   * {@link CommonConstant#DEFAULT_DELETE_FLAG_NOT}
   */
  @LogicDelete
  @Schema(title = "删除标识", description = "0-未删除")
  private Long deleteFlag;

  /**
   * 更新时间
   */
  @LastModifiedDate private Long updateTime;

  /**
   * 创建时间
   */
  @CreatedDate private Long createTime;

  /**
   * 版本号和乐观锁字段,初始为0，更新自增1
   */
  @Version private Long rowVersion;
}
